﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SilverlightPhoneDatabaseTest;
using System.Collections.ObjectModel;
using System.Xml.Serialization;
using System.IO;

namespace ConsoleCreateXmlTableApp
{
    class Program
    {
        static void Main(string[] args)
        {
            ObservableCollection<Person> coll = new ObservableCollection<Person>();
            coll.Add(new Person() { FirstName = "John", LastName = "Doe", Salary = 2, BirthDate = DateTime.Today });
            coll.Add(new Person() { FirstName = "Jane", LastName = "Doe", Salary = 1, BirthDate = DateTime.Today.AddDays(-1) });

            string content = string.Empty;

            using (StringWriter stringWriter = new StringWriter())
            {
                XmlSerializer serializer = new XmlSerializer(coll.GetType());

                serializer.Serialize(stringWriter, coll);
                stringWriter.Flush();
                content = stringWriter.GetStringBuilder().ToString();
                stringWriter.Close();
            }
            System.IO.File.WriteAllText(@"c:\test.xml", content);

            Console.Write("Create c:\test.xml with two people");
        }

    }
}
